package 力扣._26_删除有序数组中的重复项;

public class Solution {
    public int removeDuplicates(int[] nums) {
        int lastnum = nums[0];  //上一个不重复的数
        int total = 0;  //重复值的数量
        for (int i = 1; i < nums.length; i++) {
            if (lastnum != nums[i]) {
                lastnum = nums[i];
                nums[i - total] = nums[i];
            } else {
                total++;
            }
        }
        return nums.length - total;
    }
}
